package xjtu.se.articlecommunity.user.publisharticle.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import xjtu.se.articlecommunity.user.publisharticle.dto.PublishDto;

public interface PublishDao {
    @Select("select max(convert(a_id,signed)) from t_article")
    String findMaxID(PublishDto dto);

    @Insert("insert into t_article(a_id, u_id, a_title, a_html) values(#{a_id}, #{u_id}, #{a_title}, #{a_html})")
    void insertArticle(PublishDto dto);
    @Select("select a_id,u_id,a_title,a_html from t_article where a_id=#{a_id}")
    PublishDto getPublishedArticleByA_id(String a_id);
    @Select("select tab.at_tab from art_tab art,t_article_tab tab where art.at_tab=tab.at_tab and art.a_id=#{a_id}")
    String[] getArticleTabsByA_id(String a_id);
    @Update("update t_article set a_title=#{a_title}, a_html=#{a_html},a_status=0  where a_id=#{a_id}")
    void updateArticle(PublishDto dto);
}
